﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OracleClient;

namespace PM.Services
{
    public static class ReportServices
    {
        public static DataTable GetDevidends()
        {
            DataTable retVal = new DataTable();
            OracleConnection con = new OracleConnection();
            try
            {
                con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                con.Open();
                OracleCommand cmd = new OracleCommand();
                cmd.CommandText = "select COMPANY_ID,"+
                    "COMPANY_NAME, "+
                    "ANNOUNCED, RATE_OF_DIVIDEND, "+
                    "DIVIDEND_TYPE, "+
                    "FINANCIAL_YEAR, "+
                    "XD, PAYMENT, REMARKS from DIVIDEND ";
                cmd.Connection = con;

                using (IDataReader dataReader = cmd.ExecuteReader())
                {
                    if (dataReader != null)
                    {
                        retVal = new DataTable();
                        retVal.Load(dataReader);
                    }
                }
            }
            catch (System.Exception exc)
            {
                throw;
            }
            finally
            {
                con.Close();
            }

            return retVal;
        }

        public static DataTable GetUserTypes()
        {
            DataTable retVal = new DataTable();
            OracleConnection con = new OracleConnection();
            try
            {
                con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                con.Open();
                OracleCommand cmd = new OracleCommand();
                cmd.CommandText = "select USER_TYPE_ID, " +
                    "DESCRIPTION as DESCRIPTION " +
                    " from  USER_TYPE";
                cmd.Connection = con;

                using (IDataReader dataReader = cmd.ExecuteReader())
                {
                    if (dataReader != null)
                    {
                        retVal = new DataTable();
                        retVal.Load(dataReader);
                        int i = retVal.Rows.Count;
                    }
                }
            }
            catch (System.Exception exc)
            {
                throw;
            }
            finally
            {
                con.Close();
            }

            return retVal;
        }

        public static DataTable GetBankDeposits()
        {
            DataTable retVal = new DataTable();
            OracleConnection con = new OracleConnection();
            try
            {
                con.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                con.Open();
                OracleCommand cmd = new OracleCommand();
                cmd.CommandText = "select * from bank_deposits_view";
                cmd.Connection = con;

                using (IDataReader dataReader = cmd.ExecuteReader())
                {
                    if (dataReader != null)
                    {
                        retVal = new DataTable();
                        retVal.Load(dataReader);
                        int i = retVal.Rows.Count;
                    }
                }
            }
            catch (System.Exception exc)
            {
                throw;
            }
            finally
            {
                con.Close();
            }

            return retVal;
        }
    }
}
